package com.coc.ofhibernate.service.impl;

import com.coc.ofhibernate.entity.database1.People;
import com.coc.ofhibernate.entity.database2.Person;
import com.coc.ofhibernate.repository.main.MainRepository;
import com.coc.ofhibernate.repository.second.SecondRepository;
import com.coc.ofhibernate.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class TestServiceImpl implements TestService {

    @Autowired
    private MainRepository mainRepository;

    @Autowired
    private SecondRepository secondRepository;

    @Override
    public People getUerById(Integer id) {
        return mainRepository.findByUserId(id);
    }

    @Override
    public void insertPeople(People people) {
        mainRepository.save(people);
    }


    @Override
    public Person getUserById2(Integer id) {
        return secondRepository.getUserById(id);
    }

    @Override
    public void insertPerson(Person person) {
        secondRepository.save(person);
    }
}
